home *** CD-ROM | disk | FTP | other *** search
/ EuroCD 3 / EuroCD 3.iso / Emulators / v2600 / Source.lha / Source / amiga_options.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-04-24  |  3.7 KB  |  151 lines

  1. /*****************************************************************************
  2. Author     : Matthew Stroup
  3. Description: Command line parser for Amiga v2600
  4. Date       : April 24, 1997
  5.  
  6.    This file is part of v2600, the Atari 2600 Emulator
  7.    ===================================================
  8.    
  9.    Copyright 1996 Alex Hornby. For contributions see the file CREDITS.
  10.  
  11.    This software is distributed under the terms of the GNU General Public
  12.    License. This is free software with ABSOLUTELY NO WARRANTY.
  13.    
  14.    See the file COPYING for details.
  15.    
  16. ******************************************************************************/
  17.  
  18. /* Command Line Option Parser */
  19. #include "config.h"
  20. #include "options.h"
  21. #include <stdio.h>
  22. #include <stdlib.h>
  23. #include <string.h>
  24. #include "version.h"
  25.  
  26. /* Options common to all ports of x2600 */
  27. extern struct BaseOptions base_opts={1,0,0,0,0,"",0,0,1,0,0};
  28.  
  29. static void copyright(void)
  30. {
  31.     printf("\nVirtual 2600 Version %s.\nCopyright 1995/6 Alex Hornby.\n\nDistributed under the terms of the GNU General public license.\n",VERSION);
  32.     printf("Virtual 2600 comes with ABSOLUTELY NO WARRANTY; for details see file COPYING.\nThis is free software, and you are welcome to redistribute it under\ncertain conditions.\n\n");
  33. }
  34.  
  35. static void base_usage(void)
  36. {
  37. printf("usage: v2600 [options] filename\nwhere options include:\n");
  38. printf("        -h           This information\n");
  39. printf("        -v           Show the current version/copyright info\n");
  40. printf("        -f int       Set the refresh rate (1=default)\n");
  41. printf("        -n           Emulate an NTSC 2600 (default)\n");
  42. printf("        -p           Emulate a PAL 2600\n");
  43. printf("        -l <type>    Left controller, 0=JOY (default), 1=PADDLE\n");
  44. printf("        -r <type>    Right controller, 0=JOY (default), 1=PADDLE\n");
  45. printf("        -b <type>    Bank switching scheme, 0=NONE (default),1=Atari 8k,\n");
  46. printf("                     2=Atari 16k, 3=Parker 8k, 4=CBS, 5=Atari Super Chip\n");
  47. printf("        -s           Turn on sound.\n");
  48. printf("        -S           Turn off sound. (default)\n");
  49. printf("        -w           Swap the left and right control methods.\n");
  50. printf("        -j           Use real joysticks. (default)\n");
  51. printf("        -k           Use keyboard for joystick.\n");
  52. printf("        -y           Use mouse y for paddle (e.g. video olympics).\n");
  53. printf("        -V           Video output, 0=Custom Screen (default), 1=Window\n");
  54. printf("                     2='Fast but Ugly' Custom Screen\n");
  55. }
  56.  
  57. int parse_options(int argc, char **argv)
  58. {
  59. int n=1;
  60.     if (argc==1)
  61.     {
  62.         copyright();
  63.         base_usage();
  64.         exit(0);
  65.     }
  66.     while(argv[n][0]=='-')
  67.     {
  68.         switch (argv[n][1])
  69.         {
  70.             case 'h':
  71.                 copyright();
  72.                 base_usage();
  73.                 exit(0);
  74.                 break;
  75.  
  76.             case 'v':
  77.                 copyright();
  78.                 exit(0);
  79.                 break;
  80.  
  81.             case 'f':
  82.                 base_opts.rr=atoi(argv[n+1]);
  83.                 n++;
  84.                 break;
  85.         
  86.             case 'n':
  87.                 base_opts.tvtype=0;
  88.                 break;
  89.  
  90.             case 'p':
  91.                 base_opts.tvtype=1;
  92.                 break;
  93.  
  94.             case 'l':
  95.                 base_opts.lcon=atoi(argv[n+1]);
  96.                 n++;
  97.                 break;
  98.     
  99.             case 'r':
  100.                 base_opts.rcon=atoi(argv[n+1]);
  101.                 n++;
  102.                 break;
  103.  
  104.             case 'b':
  105.                 base_opts.bank=atoi(argv[n+1]);
  106.                 n++;
  107.                 break;
  108.  
  109.             case 's':
  110.                 base_opts.sound=1;
  111.                 break;
  112.  
  113.             case 'S':
  114.                 base_opts.sound=0;
  115.                 break;
  116.  
  117.             case 'w':
  118.                 base_opts.swap=1;
  119.                 break;
  120.  
  121.             case 'j':
  122.                 base_opts.realjoy=1;
  123.                 break;
  124.  
  125.             case 'k':
  126.                 base_opts.realjoy=0;
  127.                 break;
  128.  
  129.             case 'y':
  130.                 base_opts.mousey=1;
  131.                 break;
  132.  
  133.             case 'V':
  134.                 base_opts.video=atoi(argv[n+1]);
  135.                 n++;
  136.                 break;
  137.  
  138.             default:
  139.                 fprintf (stderr,"\n'%s' is not valid or is not a supported option.\n", argv[n]);
  140.         }
  141.         n++;
  142.     }
  143.     if (n<argc) strcpy(base_opts.filename, argv[n]);
  144.     else
  145.     {
  146.         printf("No filename was specified.\n");
  147.         exit(0);
  148.     }
  149.     return 0;
  150. }
  151.